



export function createTableName(baseName: string) {

    function getTableName(year: number | string = new Date().getFullYear()) {
        return `${baseName}_${year}`;
    }
    function getYears(start: Date  | number, end: Date  | number) {
        const startDate = start instanceof Date ? start :  new Date(Number(start));
        const endDate = end instanceof Date ? end :  new Date(Number(end));
        const years: (string | number)[] = []
        for (let year = startDate.getFullYear(); year <= endDate.getFullYear(); year++) {
            years.push(year);
        }
        return years;
    }
    function getFullNames(start: Date | number, end: Date | number) {
        return getYears(start, end).map(year => {
            return getTableName(year)
        })
    }
    
    return {
        getTableName,
        getYears,
        getFullNames,
    }
}